# -*- coding: UTF-8 -*-
# _auther:zhangxin
# date : 2020/7/29
import json
from functools import wraps
from util.path_utill import findCase
from util.make_ddt import MakeDdt
import re
import yaml


def readYml(ymlname):
    """
    读取yml 文件装饰器
    """

    def files(fu):
        @wraps(fu)
        def neifile(*args):
            casepath1 = findCase(__file__, ymlname)
            with open(casepath1, 'r', encoding='utf-8') as f:
                file_content = f.read()

            content = yaml.load(file_content, yaml.FullLoader)
            li = {}
            a = content['testcases'][0]
            a1 = a['request']
            li = a1
            li['expectData'] = a['validate']['expectData']
            return fu(li)

        return neifile

    return files
